package com.nidu.demo.role.convertor;

import com.nidu.demo.base.BaseConvertor;
import com.nidu.demo.convertor.MapStructConfig;
import com.nidu.demo.role.dto.RoleCO;
import com.nidu.demo.role.mapper.dataobject.RoleDO;
import com.nidu.demo.role.model.Role;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

@Mapper(config = MapStructConfig.class)
public interface RoleConvertor extends BaseConvertor<RoleDO, Role, RoleCO> {
    
    @Override
    @Mapping(target = "createTime", ignore = true)
    @Mapping(target = "updateTime", ignore = true)
    @Mapping(target = "createBy", ignore = true)
    @Mapping(target = "updateBy", ignore = true)
    @Mapping(source = "roleName", target = "name")
    @Mapping(source = "roleCode", target = "code")
    @Mapping(source = "roleType", target = "type")
    RoleDO toDataObject(Role role);

    @Override
    @Mapping(source = "name", target = "roleName")
    @Mapping(source = "code", target = "roleCode")
    @Mapping(source = "type", target = "roleType")
    Role toDomainObject(RoleDO dataObject);
}